package com.marktotop.controller;


import com.marktotop.entity.Menu;
import com.marktotop.response.ResultBean;
import com.marktotop.response.ResultCode;
import com.marktotop.service.IMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author marktotop
 * @since 2021-05-23
 */
@RestController
@RequestMapping("/system/cfg")
@Api(tags = "系统菜单接口")
public class MenuController {

    @Autowired
    private IMenuService menuService;

    /**
     * 根据id查询菜单列表
     *      id后端自己获取，不用传
     *
     * @return
     */
    @ApiOperation(value = "根据id查询菜单列表",notes="GET提交，通过用户id查询菜单列表")
    @RequestMapping(value = "/menu",method = RequestMethod.GET)
    public ResultBean getMenuList(){
        List<Menu> menus = menuService.getMenuByAdminId();
        if (null != menus){
            return ResultBean.ok().data("menus",menus);
        }
        return ResultBean.result(ResultCode.NON_RESULT);
    }
}
